<template>
	<view :style="{margin:'80px 50px 0'}">
		<uni-easyinput type="text" placeholder="用户名" v-model="username"/>
		<uni-easyinput type="password" placeholder="密码"
		               :style="{marginTop:'10px'}"
		               v-model="pwd"
		/>
		<button type="primary"
		        @click="login"
		        :style="{marginTop:'30px'}">登录
		</button>
	</view>
</template>

<script>
    import Http from "../../utils/http";
    import Toast from "../../components/common/toast";
    import RouteUtil from "../../utils/js/route-util";

    export default {
        name: "Login",

        data() {
            return {
                username: '',
                pwd: ''
            }
        },

        methods: {
            login() {
                Http.request(Http.login, {
                    user_login: this.username,
                    user_pass: this.pwd,
                    country_code: "86",
                }, {
                    onSucc(code, msg, info) {
                        if (code ===0){
                            uni.setStorageSync("user",info[0])
                            Toast.show("登录成功")
                            RouteUtil.forward(RouteUtil.LIVE_CHOOSE_SDK)
                        }else{
                            Toast.show(msg)
                        }
                       
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>
